<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id' => 'user-form',
    'enableAjaxValidation' => true,
    'enableAjaxValidation' => true,
    'type' => 'horizontal',
    'clientOptions' => array(
	'validateOnSubmit' => true,
    ),
    'htmlOptions' => array(
	'enctype' => 'multipart/form-data'
    )
	));
?>

<p class="help-block">Fields with <span class="required">*</span> are required.</p>

<?php echo $form->errorSummary($model); ?>

<?php echo $form->textFieldRow($model, 'username', array('class' => 'span5', 'maxlength' => 25)); ?>

<?php echo $form->textFieldRow($model, 'email', array('class' => 'span5', 'maxlength' => 128)); ?>

<?php echo $form->passwordFieldRow($model, 'password', array('class' => 'span5', 'maxlength' => 128)); ?>

<?php // echo $form->textFieldRow($model, 'display_name', array('class' => 'span5', 'maxlength' => 128)); ?>

<?php //echo $form->dropDownListRow($model, 'type', User::getTypeRange(), array('class' => 'span5', 'maxlength' => 25)); ?>

<?php echo $form->dropDownListRow($model, 'status', User::getStatusRange(), array('class' => 'span5')); ?>

<?php //echo $form->textFieldRow($model, 'first_name', array('class' => 'span5', 'maxlength' => 25)); ?>

<?php //echo $form->textFieldRow($model, 'last_name', array('class' => 'span5', 'maxlength' => 25)); ?>

<?php echo $form->dropDownListRow($model, 'gender', User::getGenderRangeAdmin(), array('class' => 'span5', 'maxlength' => 6)); ?>

<?php //echo $form->textFieldRow($model, 'social_provider', array('class' => 'span5', 'maxlength' => 25)); ?>

<?php //echo $form->textFieldRow($model, 'social_uid', array('class' => 'span5', 'maxlength' => 255)); ?>

<?php //echo $form->textFieldRow($model, 'access_token', array('class' => 'span5', 'maxlength' => 255)); ?>

<?php //echo $form->textAreaRow($model, 'bio', array('rows' => 6, 'cols' => 50, 'class' => 'span8')); ?>



<?php // echo $form->textFieldRow($model, 'address', array('class' => 'span5', 'maxlength' => 255)); ?>



<?php echo $form->textFieldRow($model, 'city', array('class' => 'span5', 'maxlength' => 45)); ?>
<?php echo $form->textFieldRow($model, 'state', array('class' => 'span5', 'maxlength' => 45)); ?>
<?php echo $form->textFieldRow($model, 'postcode', array('class' => 'span5', 'maxlength' => 45)); ?>
<div class="control-group">
    <label class="control-label">Country</label>
    <div class="controls">        

	<?php echo $form->dropDownList($model, 'country', Country::getSelectList()) ?>
    </div>
</div>


<?php // echo $form->textFieldRow($model, 'phone', array('class' => 'span5', 'maxlength' => 15)); ?>

<?php // echo $form->textFieldRow($model, 'telephone', array('class' => 'span5', 'maxlength' => 45)); ?>

<?php echo $form->textFieldRow($model, 'mobile', array('class' => 'span5', 'maxlength' => 45)); ?>



<div class="control-group">
    <label class="control-label">Avatar</label>
    <div class="controls">
        <img src="<?php echo $model->getAvatarUrl() ?>" title="" />
        <br/>
	<?php echo CHtml::fileField('avatar') ?>
    </div>
</div>

<div class="wrap-more-information">
    <div class='title-menu'>Information</div>
    <table>
	<tr>
	    <td class='label-column-edit-user'>Birthday: </td>
	    <td>	    
		<?php
		$day = date('d', strtotime($model->birthday));
		$month = date('m', strtotime($model->birthday));
		$yearBirth = date('Y', strtotime($model->birthday));
		?>

		Month:
		<select name="User[month]" class="short-select-sign-up">
		    <?php
		    for ($i = 1; $i <= 12; $i++) {
			if ($month == $i) {
			    echo "<option value='" . $i . "' selected>" . $i . "</option>";
			} else {
			    echo "<option value='" . $i . "'>" . $i . "</option>";
			}
		    }
		    ?>
		</select>

		Day:
		<select name="User[day]" class="short-select-sign-up">
		    <?php
		    for ($i = 1; $i <= 30; $i++) {
			if ($day == $i) {
			    echo "<option value='" . $i . "' selected>" . $i . "</option>";
			} else {
			    echo "<option value='" . $i . "'>" . $i . "</option>";
			}
		    }
		    ?>
		</select>

		Year:
		<select name="User[year]" class="year-select-sign-up">
		    <?php
		    $year = date('Y', time());
		    for ($i = 0; $i <= 50; $i++) {
			$j = $year - $i;
			if ($yearBirth == $j) {
			    echo "<option value='" . $j . "' selected>" . $j . "</option>";
			} else {
			    echo "<option value='" . $j . "'>" . $j . "</option>";
			}
		    }
		    ?>
		</select>
	    </td>
	</tr>
	<tr>
	    <td  class='label-column-edit-user'>Height</td>
	    <td><?php echo $form->dropDownList($model, 'height', User::getListHeight(), array('class' => 'select-on-profile')); ?></td>
	</tr>
	<tr>
	    <td  class='label-column-edit-user'>Marital Status</td>
	    <td><?php echo $form->dropDownList($model, 'marital', User::getListMarital(), array('class' => 'select-on-profile')); ?></td>
	</tr>
	<tr>
	    <td  class='label-column-edit-user'>Ethnicity</td>
	    <td><?php echo $form->dropDownList($model, 'ethnicity', User::getListEthnicity(), array('class' => 'select-on-profile')); ?></td>
	</tr>
	<tr>
	    <td  class='label-column-edit-user'>Relationship</td>
	    <td><?php echo $form->dropDownList($model, 'relationship', User::getListRelationship(), array('class' => 'select-on-profile')); ?></td>
	</tr>
	<tr>
	    <td  class='label-column-edit-user'>Zodiac</td>
	    <td><?php echo $form->dropDownList($model, 'zodiac', User::getListZodiac(), array('class' => 'select-on-profile')); ?></td>
	</tr>
	<tr>
	    <td  class='label-column-edit-user'>Smoking Preference</td>
	    <td><?php echo $form->dropDownList($model, 'smoking', User::getListSmoking(), array('class' => 'select-on-profile')); ?></td>
	</tr>   
	<tr>
	    <td  class='label-column-edit-user'>General Build</td>
	    <td><?php echo $form->dropDownList($model, 'general_build', User::getListBuild(), array('class' => 'select-on-profile')); ?></td>
	</tr>
	<tr>
	    <td  class='label-column-edit-user'>Children</td>
	    <td><?php echo $form->dropDownList($model, 'children', User::getListChildren(), array('class' => 'select-on-profile')); ?></td>
	</tr>
	<tr>
	    <td  class='label-column-edit-user'>Religion</td>
	    <td><?php echo $form->dropDownList($model, 'religion', User::getListReligion(), array('class' => 'select-on-profile')); ?></td>
	</tr>
    </table>

    <?php
    /*     * ************************Greeting*********************** */
    ?>
    <div class='title-menu'>Greeting</div>
    <div class="wrap-greeting">
	<?php
	foreach (Question::getGreetings() as $key => $value) {
	    ?>
    	<div>
    	    <div><?php echo h($value) ?></div>
    	    <textarea name="Question[<?php echo $key ?>]"><?php
		    if (isset($model->more_info[$key])) {
			echo $model->more_info[$key];
		    }
		    ?></textarea>
    	</div>
    	<br>
	    <?php
	}
	?>
    </div>
    <?php
    /*     * ************************Question*********************** */
    ?>
    <div class='title-menu'>Question</div>
    <div class="wrap-greeting">
	<?php
	foreach (Question::getQuestions() as $question) {
	    ?>
    	<div>
    	    Q: <?php echo $question['text'] ?><br>
    	    A: <select name="Question[<?php echo $question['question_id'] ?>]">
    		<option value="">Choose</option>
		    <?php foreach ($question['list_answer'] as $answer) { ?>
			<option value="<?php echo $answer ?>" 
			<?php
			if (isset($model->more_info[$question['question_id']])) {
			    if (strtolower($answer) == strtolower($model->more_info[$question['question_id']])) {
				echo 'selected';
			    }
			}
			?>
				><?php echo $answer ?></option>
			    <?php } ?>
    	    </select>
    	</div>
    	<br>
	    <?php
	}
	?>
    </div>
</div>
<div class="form-actions">
    <?php
    $this->widget('bootstrap.widgets.TbButton', array(
	'buttonType' => 'submit',
	'type' => 'primary',
	'label' => $model->isNewRecord ? 'Create' : 'Save',
    ));
    ?>
</div>

<?php $this->endWidget(); ?>
